package com.gin.kotlin.gf2gamecommunity.base.composable

import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier

/**
 * 整合 DropdownMenuItem 和  IconButton
 * @param icon 图标
 * @param onClick 点击事件
 * @param text DropdownMenuItem上的文字
 * @param menuItem 是否使用 DropdownMenuItem 模式
 * @param modifier Modifier
 */
@Composable
fun MenuItemButton(icon: @Composable () -> Unit, onClick: () -> Unit, text: String = "", menuItem: Boolean = false, modifier: Modifier = Modifier) {
    if (menuItem)
        DropdownMenuItem(text = { Text(text) }, leadingIcon = icon, onClick = onClick, modifier = modifier)
    else
        IconButton(onClick = onClick, content = icon, modifier = modifier)
}